<!-- #INCLUDE Virtual="/lib.asp" -->
<!-- #INCLUDE Virtual="/lib_gen.asp" -->
<!-- #INCLUDE Virtual="/lib_json.asp" -->
<?php
	include '../../lib/AppScope.pre.php';
	include '../../newlib_gen.php';
	include '../../lib/politienlversion.php';
	$version = determineVersionPolitienl()->r;
	$app->version = $version;
	$nextv = $app->version;
	$pageTitle = "Status politie.nl v" . $version;

	generatePage($_REQUEST["preview"], $_REQUEST["nextpage"], $pageTitle, $rssImage, htmlBody(!empty($version)));

	include '../../lib/AppScope.post.php';

	function htmlBody($ok) {
		$prefix = "<table class=\"traffic-light\">";
		$black = "<tr><td style=\"background-color: black;\">&nbsp;</td></tr>";
		$green = "<tr><td style=\"background-color: green;\">Ok</td></tr>";
		$red = "<tr><td style=\"background-color: red;\">Fout</td></tr>";
		$divider = "<tr><td class=\"traffic-light-space\">&nbsp;</td></tr>";
		$suffix = "</table>";
		if ($ok) {
			return $prefix . $black . $divider . $black . $divider . $green . $suffix;
		} else {
			return $prefix . $red . $divider . $black . $divider . $black . $suffix;
		}
	}
	function checkVersion($currentVersion) {
/* 
	TODO: Rewrite to PHP
	dim fname, fso, versionFile, line, newline
	
	newjson = trim(replace(current, vbcrlf, ""))
	newjson = replace(newjson, vblf, "")
	newjson = replace(newjson, vbcr, "")
	while instr(newjson, "  ") > 0
		newjson = replace(newjson, "  ", " ")
	wend
	
	set fso = Server.CreateObject("Scripting.FileSystemObject")
	versionFile = server.mappath("..\..\log\versions.log")
	
	if not fso.FileExists(versionFile) then
		set fname=fso.CreateTextFile(versionFile, true)
		fname.writeLine now() & ";" & newjson
	end if
	
	'read the last line
	set f=fso.OpenTextFile(versionFile, ForReading)
	do while f.AtEndOfStream = false
		line = f.readLine
	loop
	f.Close
	
	if len(line) then
		tmpArray = split(line, ";")
		application("versions.date") = tmpArray(0)
		oldjson = tmpArray(1)
		if oldjson <> newjson then 'a new site version is found!
			set fname=fso.OpenTextFile(versionFile, ForAppending, true)
			fname.writeLine now() & ";" & newjson
			for each sendTo in Array("sid.dane@capgemini.com", "erwin.tobben@vtspn.nl", "bruno.drenthe@vtspn.nl", "gijsbert.van.bentum@vtspn.nl")
				call sendCDOEmail("siddy@xs4all.nl", sendTo, "[POLITIEMON] New version " & application("versions.r"), "I found new version information in http://www.politie.nl/_version: " & vbcrlf & vbcrlf & newjson)
			next
		end if
	end if
	
	set fso = nothing*/		
	}
?>
